import dgram from 'dgram';
const client = dgram.createSocket('udp4');

client.on('close',()=>{
    console.log('socket已关闭');
});

client.on('error',(err)=>{
    console.log(err);
});
client.on('message',(msg,rinfo)=>{
    if(msg=='exit') client.close();
    console.log(`接收来自服务器的消息: ${rinfo.address}:${rinfo.port}:${msg}`);
});
client.send(`hello`,8060,'localhost');